#!/bin/bash
# *****************************************************************************
# file: mysqldump.sh
# date: 2014-08-28 00:22
# author: (c) by Liu Tao - <ahgigu@gmail.com>
# description: Get a mysqldump of all live databases.
# *****************************************************************************
source "bootstrap.sh"

DBUSER=$DB_USER
DBPASSWORD=$DB_PASSWORD
DBSERVER=$DB_SERVER
DB_NAMES=$DB_NAMES
DBCONN=$DB_CONN

BACKUPPATH=$BACKUP_PATH

# get current date ( YYYYMMDD )...
date=$( date +%Y%m%d )

# *****************************************************************************
# program action...

for DB in "${DB_NAMES[@]}"
do
    echo "================== Dumping ${DB} ======================"
    MYSQL_PWD=$DBPASSWORD mysqldump $DBCONN $DB | gzip -9 > ${BACKUPPATH}/${DB}_${date}.sql.gz
    #MYSQL_PWD=$DBPASSWORD mysqldump -w "latest=1" --no-create-info --skip-triggers $DBCONN $DB | gzip -9 > ${BACKUPPATH}/${DB}_${date}.sql.gz
done

echo "================== Done ======================"

# *****************************************************************************
# EOF
